package com.huawei.appgallery.foundation.ui.framework.fragment.multitabs.horizontal;

import android.content.Context;
import android.graphics.Rect;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.RecyclerView.f;
import androidx.recyclerview.widget.RecyclerView.j;
import androidx.recyclerview.widget.RecyclerView.q;
import androidx.recyclerview.widget.RecyclerView.t;
import com.huawei.appgallery.foundation.ui.framework.cardframe.bean.BaseDetailResponse;
import com.huawei.appgallery.foundation.ui.framework.cardframe.bean.BaseDetailResponse.DataFilterSwitch;
import com.huawei.appgallery.foundation.ui.framework.cardframe.widget.FilterDataLayout;
import com.huawei.appgallery.foundation.ui.framework.fragment.multitabs.MultiTabsFragment;
import com.huawei.appmarket.framework.widget.ExpandScrollLayout;
import com.huawei.appmarket.framework.widget.SimpleExpandScrollLayout;
import com.huawei.appmarket.support.widget.tabhost.FragmentTabHost;
import java.util.ArrayList;
import java.util.List;
import o.azb;
import o.chj;
import o.ciu;
import o.ciw;
import o.dgp;
import o.dky.c;
import o.dky.h;
import o.dky.i;
import o.ContentManager;
import o.MinimumFactory;
import org.jetbrains.annotations.NotNull;

public class HorizontalMultiTabsFragment extends MultiTabsFragment {
    private RecyclerView ॱॱ;
    private ciu ᐝ;

    static class d extends f {
        private boolean ˎ;

        private d() {
            this.ˎ = MinimumFactory.getBoolValue(ContentManager.getInstant().getContext());
        }

        public void ˏ(@NonNull Rect rect, @NonNull View view, @NonNull RecyclerView recyclerView, @NonNull t tVar) {
            if (recyclerView.ˋ() != null && recyclerView.ʼ(view) != recyclerView.ˋ().ˏ() - 1) {
                int dimension = (int) recyclerView.getResources().getDimension(c.ᐝ);
                if (this.ˎ) {
                    rect.left = dimension;
                } else {
                    rect.right = dimension;
                }
            }
        }
    }

    public void ˎ(@NotNull ViewGroup viewGroup) {
        this.ᴵ.inflate(i.ॱˎ, viewGroup);
    }

    public void ᵔ() {
        super.ᵔ();
        this.ॱॱ = (RecyclerView) this.ॱˍ.findViewById(h.ߺ);
        azb.ˏ(this.ॱॱ);
        if (this.ᐝ == null) {
            this.ᐝ = new ciu();
            this.ᐝ.ˎ(this);
        }
        this.ॱॱ.setAdapter(this.ᐝ);
        j linearLayoutManager = new LinearLayoutManager(ॱˋ());
        linearLayoutManager.ˊ(0);
        this.ॱॱ.setLayoutManager(linearLayoutManager);
        this.ॱॱ.ˋ(new d(), -1);
        ˎ(this.ᐝʽ);
        this.ॱʾ = (ExpandScrollLayout) this.ॱˍ.findViewById(h.ᐝˋ);
        this.ߺ = (FilterDataLayout) this.ॱˍ.findViewById(h.ˎˏ);
        this.ॱʾ.setHeadView(this.ߺ);
        this.ॱʾ.setOnScrollListener(new chj(this));
        if (this.ॱʾ instanceof SimpleExpandScrollLayout) {
            ((SimpleExpandScrollLayout) this.ॱʾ).setContentView(ˊʻ());
        }
        ॱʾ();
    }

    private void ॱʾ() {
        if (this.ॱꓸ) {
            this.ॱʾ.setHasExpandLayout(true);
            this.ॱʾ.ˋ(true);
            ˎ(this.ߺ, 0);
            this.ߺ.setDataFilterListener(this);
            if (!(this.ॱﹳ == null || ʻʽ() == null)) {
                DataFilterSwitch ʻʽ = ʻʽ();
                if (TextUtils.isEmpty(this.ॱﹳ.ˏ()) || this.ॱﹳ.ˏ().equals(ʻʽ.ˏ())) {
                    this.ॱﹳ = ʻʽ;
                }
            }
            this.ߺ.setFilterData(this.ॱﹳ);
            return;
        }
        this.ॱʾ.setHasExpandLayout(false);
        this.ॱʾ.ˋ(false);
        ˎ(this.ߺ, 8);
    }

    public void ॱॱ(@NotNull BaseDetailResponse<?> baseDetailResponse) {
        if (!ʼॱ()) {
            super.ॱॱ((BaseDetailResponse) baseDetailResponse);
            ˎ(this.ᐝʽ);
            if (baseDetailResponse != null) {
                ˏ(baseDetailResponse.ʽॱ());
            }
            ॱʾ();
            ߺ();
        }
    }

    private void ߺ() {
        DataFilterSwitch ʻʽ = ʻʽ();
        if (ʻʽ != null && this.ॱﹳ != null && !this.ॱﹳ.equals(ʻʽ)) {
            FilterDataLayout.ˋ(this.ॱﹳ);
            ʴ();
        }
    }

    private void ͺ(int i) {
        Context ॱˊ = ॱˊ();
        j ʻ = this.ॱॱ.ʻ();
        if (ॱˊ != null && ʻ != null) {
            q o_ciw = new ciw(ॱˊ);
            o_ciw.ॱ(i);
            ʻ.ॱ(o_ciw);
        }
    }

    public void ˏॱ(int i) {
        super.ˏॱ(i);
        if (this.ᐝ != null) {
            this.ᐝ.ʽ(i);
            this.ᐝ.ˊ();
            ͺ(this.ᐝ.ॱ());
        }
    }

    public void ʼ(int i) {
        FragmentTabHost ˊʻ = ˊʻ();
        if (ˊʻ != null) {
            ˊʻ.setCurrentTab(i);
        }
        ͺ(i);
        ˊॱ(i);
    }

    public void ˎ(@NotNull List<? extends dgp> list) {
        this.ᐝ.ˋ(new ArrayList(this.ᐝʽ));
        this.ᐝ.ʽ(י());
        this.ᐝ.ˊ();
    }
}
